<template>
	<view class="voucherDetail">
		<view class="voucher_list">
			<view class="voucher_list_item"> 
				<view class="voucher_list_item_top">
					<view class="voucher_list_item_top_left">
						<view class="voucher_list_item_top_left_money">
							<text class="voucher_list_item_top_left_money_amount">{{voucherDetailObj.cate==1?'肥料券':voucherDetailObj.cate==2?'参观券':'指导券'}}</text>
						</view>
						<text class="voucher_list_item_top_left_fullmoney">共{{voucherDetailObj.count}}张</text>
					</view>
					<view class="voucher_list_item_top_right">
						<view class="voucher_list_item_top_right_information">
							<view class="voucher_list_item_top_right_information_effect">
								<text class="voucher_list_item_top_right_information_effect_left">{{voucherDetailObj.name}}</text>
							</view>
							<view class="voucher_list_item_top_right_information_cxtravalue">
								<text class="voucher_list_item_top_right_information_time">有效期至 {{voucherDetailObj.startTimeText}}</text>  
							</view>  
						</view> 
					</view>
				</view>
				<view class="voucher_list_item_bottom">
					<view class="voucher_list_item_bottom_condition">
						<text class="voucher_list_item_bottom_condition_text" :class="[voucherDetailObj.isImage&&'voucher_list_item_bottom_condition_extext']">
							{{voucherDetailObj.useRule}}
						</text>
					</view> 
				</view>
				<view style="width: 100%;text-align: center"> 
					<img  class="voucher_list_item_canvas" style="margin: 0 auto;" :src='codeImg'/> 
				</view> 
 		       <view class="voucher_list_item_codeText">
					向业务员出示二维码
				</view> 
				<view class="voucher_list_item_codeTime">
					券码信息：{{voucherDetailObj.expire_format}}到期
				</view> 
			</view>
		</view>		 
	</view>
</template>

<script>    
	 	export default {  
			data() {
				return {
					voucherDetailObj:{}, 
					codeImg:''
				}
			}, 
			onLoad(options) {  
				console.log(options,'options')
				const { voucherDetailObj } = options
				this.voucherDetailObj = JSON.parse(voucherDetailObj) 
				console.log(this.voucherDetailObj,'this.voucherDetailObj')
				uni.setNavigationBarTitle({
					title: this.voucherDetailObj.name 
				});
				this.getCodeImage() 
			},
			methods:{  
				getCodeImage(){
					//生成券的二维码
					let self = this;
					self._postBody('user/coupon/showWriteOffCode', {
						// envVersion	要打开的小程序版本。正式版为release，体验版为trial，开发版为develop。默认是正式版。
						envVersion:'trial',
						userCouponId:self.voucherDetailObj.userCouponId
					}, function(res) {
						const { data } = res;
						 let Url = "data:image/png;base64," + data;
						self.codeImg = Url
					});
					
				}
				
			}
		}
</script>

<style lang="less" scoped>
	.voucherDetail {  
		height: 90vh;
		overflow: hidden;
	}
	.voucher_list{
		margin-top: 46rpx;
		padding:0 30rpx 30rpx ;  
		&_item::before{
			    content: ' '; 
				width:16rpx;
				height: 25rpx;  
				background: #D8D8D8; 
				border-radius: 0 16rpx 16rpx 0;
			    position: absolute;  
			    top: 280rpx;
			    left: 0;    
				opacity: 0.2; 
		}  
		&_item::after{
			    content: ' '; 
				width:16rpx;
				height: 25rpx;  
				background: #D8D8D8; 
				border-radius: 16rpx 0 0 16rpx;
			    position: absolute;  
			    top: 280rpx;
			    right: 0;    
				opacity: 0.2; 
		} 
		&_item{ 
			position: relative;
			padding: 0 20rpx 30rpx;
			margin-top: 30rpx; 
			box-shadow: 0px 0px 40rpx 4px rgba(91, 74, 40, 0.1);
			border-radius: 8rpx; 
			background-color: #fff;    
			&_top{
				padding: 24rpx 0;
				display: flex;
				align-items: flex-start;
				&_left{
					width: 188rpx;
					height: 152rpx;
					background: linear-gradient(315deg, #F6E3B8 0%, #DAB279 100%);
					border-radius: 12rpx;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					margin-right: 20rpx;
					&_money{
						display: flex;
						align-items: center;
						&_sign{
							font-size: 24rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #FFFFFF;
							line-height: 34rpx;
							margin-top: 30rpx;
						}
						&_amount{
							font-size: 48rpx;
							font-family: PingFangSC-Medium, PingFang SC;
							font-weight: 500;
							color: #735116;
							line-height: 84rpx;
						}
					}
					&_fullmoney{
						font-size: 24rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #735116;
						line-height: 34rpx;
					}
				} 
				&_right{
					display: flex;
					// justify-content: space-between;
					// align-items: center;
					flex: 1;
					min-height: 152rpx;
					&_information{
						flex: 1;
						display: flex;
						flex-direction: column;
						justify-content: space-between;
						&_effect{
							display: flex;
							align-items: flex-start;
							&_left{
								flex: 1;
								font-size: 28rpx;
								font-family: PingFangSC-Medium, PingFang SC;
								font-weight: 500;
								color: #333333;
								line-height: 40rpx;
								margin-right: 8rpx;
							}
							&_right{
								width: 98rpx;
								height: 32rpx;
								background: #FFFFFF;
								border-radius: 4rpx;
								border: 2rpx solid #FF5100;
								font-size: 20rpx;
								font-family: PingFangSC-Regular, PingFang SC;
								font-weight: 400;
								color: #FF5100;
								line-height: 28rpx;
								text-align: center;
								box-sizing: border-box;
								margin-top: 4rpx;
							}
							&_vipright{
								margin-left: 16rpx;
							}
							&_used{
								border-color:#C8C8C8;
								color: #C8C8C8;
							}
							&_vipright{
								border-color:#735116;
								color: #735116;
							}
							&_stale{
								background-color: #C8C8C8;
							}
						}
						&_cxtravalue{
							display: flex;
							align-items: center;
							justify-content: space-between;
						}
						&_time{
							font-size: 24rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #999999;
							line-height: 34rpx;
						}
						&_amount{
							font-size: 24rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #999999;
							line-height: 34rpx;
						}
						&_used{
							color: #999999;
						}
						&_stale{
							color: #999999;
						}
					}
					&_status{
						display: flex;
						align-items: center;
						&_text{
							width: 124rpx;
							height: 48rpx;
							background: #FFFFFF;
							border-radius: 26rpx;
							border: 2rpx solid #077840;
							font-size: 22rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #077840;
							line-height: 44rpx;
							text-align: center;
							box-sizing: border-box;
						}
						&_secondly{
							border: 2rpx solid #FF5100;
							color: #FF5100;
						}
						&_thirly{
							border: 2rpx solid #2F80F6;
							color: #2F80F6;
						}
						&_fourthly{
							border: 2rpx solid #242C3B;
							color: #242C3B;
						}
					}
					&_boximage{
						width: 136rpx;
						display: flex;
						align-items: center;
						image{
							width: 136rpx;
							height: 114rpx;
							vertical-align: top;
						}
					}
				}
			}
			&_bottom{
				padding: 24rpx 0;
				border-top: 2rpx dashed #E5E5E5;
				display: flex;
				justify-content: space-between;
				&_condition{
					display: flex;
					flex-direction: column;
					width: calc( 100% - 50rpx );
					&_text{
						font-size: 24rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #999999;
						line-height: 34rpx;
						margin-bottom: 20rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}
					&_extext{
						overflow:inherit;
						text-overflow: inherit;
						white-space: inherit;
					}
				}
				&_imageview{
					height: 34rpx;
					width: 44rpx;
					margin-right: -10rpx;
					display: flex;
					align-items: center;
					justify-content: center;
				}
				&_image{
					width: 24rpx;
					height: 14rpx;
					vertical-align: top;
					// margin-top: 10rpx;
					// margin-left: 24rpx;
					transform: rotate(0);
					// transition: 0.3s ease-in-out;
				}
				&_eximage{
					transform: rotate(-180deg);
				}
			} 
		    &_canvas {
				width: 256px;
				height: 256px;
				 
			}
			&_codeText{
				text-align: center;
				color: #999;
				font-size: 30rpx; 
			}  
			&_codeTime{
				text-align: center;
				color: #333;
				font-size: 30rpx;
				margin-top: 40rpx; 
			}
		}
	}
</style>
